home *** CD-ROM | disk | FTP | other *** search
/ World of Amiga / World of Amiga.iso / archive / compression / lister12.lha / ListZoo.c < prev    next >
Encoding:
Text File  |  1992-04-01  |  2.0 KB  |  79 lines

  1. /* List a zoo archive */
  2.  
  3. BOOL
  4. ListZoo(ULONG type,UBYTE *infile)
  5. {
  6.   int time, date, done;
  7.   ULONG uncomp, comp, pntr, tfiles = 0, tcomp = 0, tuncomp = 0;
  8.   UBYTE name [256], dir[256],together[512], b[200], time_str[25];
  9.   FILE *fp;
  10.  
  11.   fp = OpenFile(type,infile);
  12.  
  13.   ReadBuf (35,fp,b);
  14.  
  15.   /* Determine if it is a Zoo file */
  16.   if (strnicmp(ZOO_SIG,b,4) != 0)
  17.     {
  18.       fclose (fp);
  19.       return (WRONG_ARCHIVE);
  20.     }
  21.  
  22.   /* Pointer to next header */
  23.   pntr = GetLong (b,27);
  24.  
  25.   /* Read in the File Info */
  26.   fseek(fp,pntr,SEEK_SET);
  27.  
  28.   ReadBuf(58,fp,b);
  29.  
  30.   /* Read in the filename and Directory name */
  31.   fread (name,b[56],1,fp);
  32.   fread (dir,b[57],1,fp);
  33.  
  34.   /* Check to see if Directory and Long name present */
  35.   if (!b[57] && !b[56]) sprintf(together,"%s",b+38);
  36.    else if (!b[57] && b[56]) sprintf(together,"%s",name);
  37.     else if (b[57] && !b[56]) sprintf(together,"%s/%s",dir,b+38);
  38.      else sprintf(together,"%s/%s",dir,name);
  39.  
  40.   /* Print out header info to standard output */
  41.   InitList(ZOO,infile);
  42.  
  43.   done = FALSE;
  44.   pntr = GetLong (b,9);
  45.   while (!done)
  46.    {
  47.      /* Calculate Compressed, Uncompressed, Date,Time, and print it out */
  48.      comp = GetLong(b,27);
  49.      uncomp = GetLong(b,23);
  50.      date = b[15] * 256 + b[14];
  51.      time = b [17] * 256 + b[16];
  52.      if (MSDog (time,date,time_str) == ABORT) break;
  53.      PrintList(together, uncomp, comp,&tfiles,&tcomp,&tuncomp,time_str);
  54.  
  55.      fseek (fp,pntr,SEEK_SET);
  56.  
  57.      ReadBuf (51,fp,b);
  58.  
  59.      pntr = GetLong(b,9);
  60.      if (!pntr) break;
  61.  
  62.      fread (b+51,7,1,fp);
  63.      /* Read in the filename and Directory name */
  64.      fread (name,b[56],1,fp);
  65.      fread (dir,b[57],1,fp);
  66.  
  67.      /* Check to see if Directory and Long name present */
  68.      if (!b[57] && !b[56]) sprintf(together,"%s",b+38);
  69.       else if (!b[57] && b[56]) sprintf(together,"%s",name);
  70.        else if (b[57] && !b[56]) sprintf(together,"%s/%s",dir,b+38);
  71.         else sprintf(together,"%s/%s",dir,name);
  72.   }
  73.  
  74.   fclose (fp);
  75.   /* Print ending stats */
  76.   EndStats(tfiles,tcomp,tuncomp);
  77.   return (TRUE);
  78. }
  79.